/**
 * @param {number[]} nums
 * @return {number}
*/
var minMoves = function(nums) {
  let min = Math.min(...nums), sum = 0;
  for(let i = 0; i < nums.length; i++) {
    sum += nums[i] - min;
  }
  return sum;
};
let nums = [1,2,3];
console.log(minMoves(nums));
nums = [1,1,1];
console.log(minMoves(nums));
